//
//  RHChoiceMultipleDeviceCell.m
//  RuiHeApp
//
//  Created by Yan Chen on 2024/12/31.
//

#import "RHChoiceMultipleDeviceCell.h"
#import "RHDeviceModel.h"

@interface RHChoiceMultipleDeviceCell()
@property (nonatomic ,strong) QMUILabel *devNameLab;

@property (nonatomic ,strong) UIImageView *markView;

@end
@implementation RHChoiceMultipleDeviceCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        [self setupUI];
    }
    return self;
}



- (void)setupUI{
    
    
    QMUILabel *devNameTitleLab = [[QMUILabel alloc] init];
    [devNameTitleLab setTextAlignment:NSTextAlignmentLeft];
    [devNameTitleLab setFont:kBOLDSYSTEMFONT(14)];
    [devNameTitleLab setTextColor:FontColor(@"#3F4443")];
    devNameTitleLab.text = [NSString stringWithFormat:@"%@:",@"设备名称".rh_localized];
    devNameTitleLab.numberOfLines = 2;
    devNameTitleLab.adjustsFontSizeToFitWidth = YES;
    devNameTitleLab.minimumScaleFactor = 0.8;
    [self.contentView addSubview:devNameTitleLab];

    
    _devNameLab = [[QMUILabel alloc] init];
    [_devNameLab setTextAlignment:NSTextAlignmentCenter];
    [_devNameLab setFont:kSYSTEMFONT(14)];
    [_devNameLab setTextColor:FontColor(@"#3F4443")];
    _devNameLab.adjustsFontSizeToFitWidth = YES;
    _devNameLab.minimumScaleFactor = 0.8;
    [self.contentView addSubview:_devNameLab];
    
    
    

    
    _markView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"choice_normal"]];
    [_markView setBackgroundColor:UIColor.clearColor];
    [self.contentView addSubview:_markView];
    
    
    
    kWeakSelf;
    [devNameTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(22);
        make.right.equalTo(weakSelf.devNameLab.mas_left).offset(-5);
        make.centerY.mas_offset(0);
       
    }];
    
    [_devNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.contentView.mas_centerX).offset(-15);
        make.right.equalTo(weakSelf.markView.mas_left).offset(-5);
        make.centerY.equalTo(devNameTitleLab);
    }];
    
    [_markView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(15, 15));
        make.right.mas_offset(-22);
        make.centerY.mas_offset(0);
    }];
    
}

-(void)setDeviceModel:(RHDeviceModel *)deviceModel
{
    _deviceModel = deviceModel;
    self.devNameLab.text = deviceModel.deviceId;
    _markView.image = [UIImage imageNamed:deviceModel.isSelected?@"choice_selected":@"choice_normal"];
}



@end
